import {View, Text, StyleSheet, Button} from 'react-native';
import React from 'react';
import {useNavigation} from '@react-navigation/native';

export default function Detail({route}) {
  const navigation = useNavigation();
  const {params} = route;
  console.log('params', params);

  const setParams = () => {
    navigation.setParams({name: '更新后的李四'});
  };

  const setTitle = () => {
    navigation.setOptions({title: '标题'});
  };

  return (
    <View style={styles.container}>
      <Text>Detail</Text>
      <Button onPress={() => navigation.navigate('My')} title="跳转至 my" />
      <Button onPress={() => navigation.goBack()} title="返回" />
      <Button onPress={setParams} title="更新参数" />
      <Button onPress={setTitle} title="更新标题" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});
